/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vn.edu.vttu.taikhoan;

import java.awt.Dimension;
import java.awt.Graphics;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.TableModel;
import vn.edu.vttu.dichvu.QuanLy_DichVu;
import vn.edu.vttu.khachhang.KhachHang_QuanLy;
import vn.edu.vttu.model.KhachHang;
import vn.edu.vttu.nhanvien.NhanVien_QuanLy;
import vn.edu.vttu.phong.Phong_Quanly;
import vn.edu.vttu.phong.QuanLy_LoaiPhong;
import vn.edu.vttu.readxml.ReadXML;
import vn.edu.vttu.readxml.thongtindb;
import vn.edu.vttu.thietbi.QuanLy_ThietBi;
import vn.edu.vttu.thongke.ThongKeDichVu;

/**
 *
 * @author Administrator
 */
public class frmMain extends javax.swing.JFrame {

    /**
     * Creates new form frmMain
     */
    public frmMain() {
        initComponents();   
        try {
            ReadXML read = new ReadXML();
            Registry registry = LocateRegistry.getRegistry(read.getInfo("ipServer"), Integer.parseInt(read.getInfo("portserver")));
            vn.edu.vttu.RMI_Interface common = (vn.edu.vttu.RMI_Interface) registry.lookup("ServerKhachSan");
            String str = common.thongtindb();
            String[] mang= new String[5];
            mang=str.split("-");
            thongtindb.setDb(mang[0]);
            thongtindb.setIp(mang[1]);
            thongtindb.setP(mang[2]);
            thongtindb.setU(mang[3]);            
            thongtindb.setPort(mang[4]);               
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        if(thongtindangnhap.getIdchucvu()==7){
            phanquyen(false);
        }
    }

    private void phanquyen(boolean b) {        
        menuQuanLyNguoiDung.setEnabled(b);       
        menu_quanlydichvu.setEnabled(b);
        menu_quanlynhanvien.setEnabled(b);                
        menu_hethong.setEnabled(b);                                   
        menu_thietbi.setEnabled(b);                
        menu_loaiphong.setEnabled(b);                
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel(){
            ImageIcon icon = new ImageIcon("src/vn/edu/vttu/img/background.png");
            public void paintComponent(Graphics g){
                Dimension d = getSize();
                g.drawImage(icon.getImage(), 0, 0, d.width, d.height, null);
                setOpaque(false);
                super.paintComponent(g);
            }
        };
        jMenuBar1 = new javax.swing.JMenuBar();
        menu_hethong = new javax.swing.JMenu();
        menuQuanLyNguoiDung = new javax.swing.JMenuItem();
        menu_Thoat = new javax.swing.JMenuItem();
        menu_quanly = new javax.swing.JMenu();
        menu_quanlynhanvien = new javax.swing.JMenuItem();
        menu_quanlyphong = new javax.swing.JMenuItem();
        menu_quanlydichvu = new javax.swing.JMenuItem();
        menu_khachhang = new javax.swing.JMenuItem();
        menu_loaiphong = new javax.swing.JMenuItem();
        menu_thietbi = new javax.swing.JMenuItem();
        menu_thongke = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("PHẦN MỀM QUẢN LÝ KHÁCH SẠN");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setExtendedState(MAXIMIZED_BOTH);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 669, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 424, Short.MAX_VALUE)
        );

        menu_hethong.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/Categories-preferences-system-icon.png"))); // NOI18N
        menu_hethong.setText("Hệ Thống");

        menuQuanLyNguoiDung.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/User-Group-icon.png"))); // NOI18N
        menuQuanLyNguoiDung.setText("Quản lý Người Dùng");
        menuQuanLyNguoiDung.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuQuanLyNguoiDungActionPerformed(evt);
            }
        });
        menu_hethong.add(menuQuanLyNguoiDung);

        menu_Thoat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/Apps-session-logout-icon.png"))); // NOI18N
        menu_Thoat.setText("Thoát");
        menu_Thoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_ThoatActionPerformed(evt);
            }
        });
        menu_hethong.add(menu_Thoat);

        jMenuBar1.add(menu_hethong);

        menu_quanly.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/sewing-machine-icon (1).png"))); // NOI18N
        menu_quanly.setText("Quản Lý");

        menu_quanlynhanvien.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/eyes-office-women-glasses-icon.png"))); // NOI18N
        menu_quanlynhanvien.setText("Nhân Viên");
        menu_quanlynhanvien.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_quanlynhanvienActionPerformed(evt);
            }
        });
        menu_quanly.add(menu_quanlynhanvien);

        menu_quanlyphong.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/New-room-icon.png"))); // NOI18N
        menu_quanlyphong.setText("Phòng");
        menu_quanlyphong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_quanlyphongActionPerformed(evt);
            }
        });
        menu_quanly.add(menu_quanlyphong);

        menu_quanlydichvu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/Steak-icon.png"))); // NOI18N
        menu_quanlydichvu.setText("Dịch Vụ");
        menu_quanlydichvu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_quanlydichvuActionPerformed(evt);
            }
        });
        menu_quanly.add(menu_quanlydichvu);

        menu_khachhang.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/User-Group-icon.png"))); // NOI18N
        menu_khachhang.setText("Khách Hàng");
        menu_khachhang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_khachhangActionPerformed(evt);
            }
        });
        menu_quanly.add(menu_khachhang);

        menu_loaiphong.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/Star-icon.png"))); // NOI18N
        menu_loaiphong.setText("Loại Phòng");
        menu_loaiphong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_loaiphongActionPerformed(evt);
            }
        });
        menu_quanly.add(menu_loaiphong);

        menu_thietbi.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/sewing-machine-icon.png"))); // NOI18N
        menu_thietbi.setText("Thiết Bị");
        menu_thietbi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_thietbiActionPerformed(evt);
            }
        });
        menu_quanly.add(menu_thietbi);

        jMenuBar1.add(menu_quanly);

        menu_thongke.setIcon(new javax.swing.ImageIcon(getClass().getResource("/vn/edu/vttu/img/Statistics-icon.png"))); // NOI18N
        menu_thongke.setText("Thống Kê Dịch Vụ");
        menu_thongke.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                menu_thongkeMouseClicked(evt);
            }
        });
        menu_thongke.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_thongkeActionPerformed(evt);
            }
        });
        jMenuBar1.add(menu_thongke);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        getAccessibleContext().setAccessibleDescription("");

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void menuQuanLyNguoiDungActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuQuanLyNguoiDungActionPerformed
        QuanLyTaiKhoan quanlytaikhoan = new QuanLyTaiKhoan();
        quanlytaikhoan.setVisible(true);
    }//GEN-LAST:event_menuQuanLyNguoiDungActionPerformed

    private void menu_ThoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_ThoatActionPerformed
        System.exit(0);
    }//GEN-LAST:event_menu_ThoatActionPerformed

    private void menu_quanlynhanvienActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_quanlynhanvienActionPerformed
        NhanVien_QuanLy nv_ql = new NhanVien_QuanLy();
        nv_ql.setVisible(true);

    }//GEN-LAST:event_menu_quanlynhanvienActionPerformed

    private void menu_quanlyphongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_quanlyphongActionPerformed
        Phong_Quanly phong = new Phong_Quanly();
        phong.setVisible(true);
    }//GEN-LAST:event_menu_quanlyphongActionPerformed

    private void menu_khachhangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_khachhangActionPerformed
        KhachHang_QuanLy khachhang = new KhachHang_QuanLy();
        khachhang.setVisible(true);
    }//GEN-LAST:event_menu_khachhangActionPerformed

    private void menu_quanlydichvuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_quanlydichvuActionPerformed
        QuanLy_DichVu dv = new QuanLy_DichVu();
        dv.setVisible(true);
    }//GEN-LAST:event_menu_quanlydichvuActionPerformed

    private void menu_loaiphongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_loaiphongActionPerformed
        QuanLy_LoaiPhong lp = new QuanLy_LoaiPhong();
        lp.setVisible(true);
    }//GEN-LAST:event_menu_loaiphongActionPerformed

    private void menu_thongkeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_thongkeActionPerformed
        
    }//GEN-LAST:event_menu_thongkeActionPerformed

    private void menu_thietbiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_thietbiActionPerformed
        QuanLy_ThietBi thietbi = new QuanLy_ThietBi();
        thietbi.setVisible(true);
    }//GEN-LAST:event_menu_thietbiActionPerformed

    private void menu_thongkeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_menu_thongkeMouseClicked
       ThongKeDichVu dv = new ThongKeDichVu();
        dv.setVisible(true);
    }//GEN-LAST:event_menu_thongkeMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                frmMain frm = new frmMain();
                frm.setVisible(true);
                frm.setExtendedState(frm.getExtendedState() | JFrame.MAXIMIZED_BOTH);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JMenuItem menuQuanLyNguoiDung;
    private javax.swing.JMenuItem menu_Thoat;
    private javax.swing.JMenu menu_hethong;
    private javax.swing.JMenuItem menu_khachhang;
    private javax.swing.JMenuItem menu_loaiphong;
    private javax.swing.JMenu menu_quanly;
    private javax.swing.JMenuItem menu_quanlydichvu;
    private javax.swing.JMenuItem menu_quanlynhanvien;
    private javax.swing.JMenuItem menu_quanlyphong;
    private javax.swing.JMenuItem menu_thietbi;
    private javax.swing.JMenu menu_thongke;
    // End of variables declaration//GEN-END:variables
}
